package cn.com.oil.common.result;


import cn.com.oil.common.enums.ResultCode;
import lombok.Data;

/**
 * @author Wangtc
 * @date 2020/11/10 14:01
 */
@Data
public class Result<T> {


    private Boolean success;
    private ResultCode resultCode;
    private T data;


    private Result(Boolean success, ResultCode resultCode, T data) {
        this.success = success;
        this.resultCode = resultCode;
        this.data = data;
    }


    public static <T> Result<T> success(T data) {
        return new Result<>(Boolean.TRUE, ResultCode.SUCCESS, data);
    }

    public static <T> Result<T> fail(T data) {
        return new Result<>(Boolean.FALSE, ResultCode.FAIL, data);
    }

    public static <T> Result<T> result(Boolean success, ResultCode resultCode, T data) {
        return new Result<>(success, resultCode, data);
    }
}
